<template>
    <div class="treaty">
        <!-- 新增来源弹窗 -->
        <el-dialog 
            :title="title" 
            :visible.sync="dialogVisible" 
            width="90%" 
            top="10vh"
            :close-on-click-modal="false"
        >
            <div class="treaty-title">条款信息</div>
            <hr />
            <!-- 条款迁移路径设置 -->
            <template v-if="['外规单个复制', '外规多个复制'].includes(sourceSettteingType)">
                <div class="card-title">条款迁移路径设置</div>
                <div class="card-content">
                    <el-form :inline="true" :model="removal" label-width="125px">
                        <el-row class="form-row">
                            <el-col :span="12">
                                <el-form-item label="迁移来源类型:">
                                    <el-select v-model="removal.sourceType" placeholder="请选择" size="mini" @change="changeSourceType">
                                        <el-option 
                                            :label="item.dictKeyName"
                                            :value="item.dictKey" 
                                            v-for="(item) in indexSourceCodeSelect" 
                                            :key="item.dictKey"
                                        >{{item.dictKeyName}}</el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="迁移来源名称:">
                                    <el-select v-model="removal.indexSourceName" placeholder="请选择" size="mini">
                                        <el-option 
                                            :label="item.dictKeyName" 
                                            :value="item.dictKey" 
                                            v-for="(item) in indexSourceCodeSelect1" 
                                            :key="item.dictKey"
                                        >{{item.dictKeyName}}</el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </template>
            
            <!-- 条款基础信息-新增、修改、查看 -->
            <template v-if="!['外规多个复制'].includes(sourceSettteingType)">
                <div class="card-title">条款基础信息</div>
                <div class="card-content">
                    <el-form :inline="true" :model="indexClause" label-width="105px">
                        <el-row class="form-row" v-if="this.sourceSettteingType != '外规单个复制'">
                            <el-col :span="7">
                                <el-form-item label="条款序号:">
                                    <span style="position: absolute;left:-10px;color: red">*</span>
                                    <el-input v-model="indexClause.clauseCode" size="mini" disabled style="width: 105%"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="7">
                                <el-form-item 
                                    label="来源类型:" 
                                    v-if="['外规新增', '外规修改', '外规查看', '外规复核查看', '外规复核修改'].includes(sourceSettteingType)"
                                >
                                    <span style="position: absolute;left:-10px;color: red">*</span>
                                    <el-select 
                                        v-model="indexClause.sourceType" 
                                        placeholder="请选择" size="mini" 
                                        :disabled="['外规查看', '外规复核查看', '外规新增', '外规修改', '外规复核查看', '外规复核修改'].includes(sourceSettteingType)"
                                    >
                                        <el-option 
                                            :label="item.dictKeyName"
                                            :value="item.dictKey" 
                                            v-for="(item) in indexSourceCodeSelect" 
                                            :key="item.dictKey"
                                        >{{item.dictKey}}  {{item.dictKeyName}}</el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item 
                                    label="产品信息:" 
                                    v-else-if="['产品新增', '产品修改', '产品查看', '产品复核修改', '产品复核查看'].includes(sourceSettteingType)">
                                    <span style="position: absolute;left:-10px;color: red">*</span>
                                    <el-select 
                                        v-model="indexClause.belongFund" 
                                        placeholder="请选择" 
                                        size="mini" 
                                        :disabled="['产品新增', '产品修改', '产品查看', '产品复核修改', '产品复核查看'].includes(sourceSettteingType)"
                                    >
                                        <el-option 
                                            :label="item.dictKeyName" 
                                            :value="item.dictKey" 
                                            v-for="(item) in fundByFundTypeList" 
                                            :key="item.dictKey"
                                        >{{item.dictKey}}  {{item.dictKeyName}}</el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="7">
                                <el-form-item label="来源名称:" v-if="['外规新增', '外规修改', '外规查看', '外规复核修改', '外规复核查看'].includes(sourceSettteingType)">
                                    <span style="position: absolute;left:-10px;color: red">*</span>
                                    <el-select v-model="indexClause.indexSourceCode" placeholder="请选择" size="mini" :disabled="['外规查看', '外规新增', '外规修改', '外规复核查看', '外规复核修改'].includes(sourceSettteingType)">
                                        <el-option 
                                            :label="item.dictKeyName" 
                                            :value="item.dictKey" 
                                            v-for="(item) in indexSourceCodeSelect1" 
                                            :key="item.dictKey"
                                        >{{item.dictKey}}  {{item.dictKeyName}}</el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="产品类型:" v-else>
                                    <span style="position: absolute;left:-10px;color: red">*</span>
                                    <el-select 
                                        v-model="indexClause.fundType" 
                                        placeholder="请选择" 
                                        size="mini" 
                                        :disabled="['产品新增', '产品查看', '产品修改', '产品复核修改', '产品复核查看'].includes(sourceSettteingType)"
                                    >
                                        <el-option
                                            v-for="item in FundTypes"
                                            :key="item.dictKey"
                                            :value="item.dictKey"
                                            :label="item.dictKey + ' ' + item.dictKeyName"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="3">
                                <el-form-item label="">
                                    <el-radio-group v-model="indexClause.clauseStatus" :disabled="disabledAll">
                                        <el-radio :label="true">启用</el-radio>
                                        <el-radio :label="false">禁用</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col :span="7">
                                <el-form-item label="版本号:">
                                    <span style="position: absolute;left:-10px;color: red">*</span>
                                    <el-select v-model="indexClause.versionNumber" placeholder="请选择" size="mini" :disabled="disabledAll">
                                        <el-option 
                                            :label="item.dictKey+'-'+item.dictKeyName" 
                                            :value="item.dictKey" 
                                            v-for="(item) in VersionNums" 
                                            :key="item.dictKey"
                                        >{{item.dictKeyName}}</el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="7">
                                <el-form-item label="条款号:" v-if="['外规新增', '外规修改', '外规查看', '外规复核修改', '外规复核查看', '外规单个复制'].includes(sourceSettteingType)">
                                    <el-input v-model="indexClause.clauseNo" size="mini" style="width: 105%" :disabled="disabledAll"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="3" v-if="this.sourceSettteingType == '外规单个复制'">
                                <el-form-item label="">
                                    <el-radio-group v-model="indexClause.clauseStatus" :disabled="disabledAll">
                                        <el-radio :label="true">启用</el-radio>
                                        <el-radio :label="false">禁用</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col :span="24">
                                <el-form-item label="条款原文:">
                                    <span style="position: absolute;left:-10px;color: red">*</span>
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.clauseText"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:67vw"
                                         :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col :span="24">
                                <el-form-item label="执行标准:">
                                    <span style="position: absolute;left:-10px;color: red">*</span>
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.executiveStandard"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:67vw"
                                         :disabled="disabledAll"
                                    ></el-input>
                                    <div style="display:flex">
                                        <div>附件:</div>
                                        <el-upload  
                                            :multiple="true" 
                                            :action="actionUrl" 
                                            :headers='headerObj'
                                            :with-credentials='true'
                                            list-type="text"
                                            :show-file-list="false"
                                            :disabled="disabledAll"
                                            :on-success="function (res, file, fileList) {return uploadFileSuccess(res, file, fileList, '执行标准')}"
                                        >
                                            <el-button size="small" icon="el-icon-plus" style="border:none" :disabled="disabledAll">添加文件</el-button>
                                        </el-upload>
                                    </div>
                                    <UploadFileShow
                                        :fileList="fileList1"
                                        @emitDownLoadFile="downLoadFileBtn"
                                        @emitConfirmDelFile="confirmDelFile1"
                                    ></UploadFileShow>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col :span="24">
                                <el-form-item label="托管行意见:">
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.depositOpinions"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:67vw"
                                         :disabled="disabledAll"
                                    ></el-input>
                                    <div style="display:flex">
                                        <div>附件:</div>
                                        <el-upload  
                                            :multiple="false" 
                                            :action="actionUrl"  
                                            :headers='headerObj'
                                            :with-credentials='true'
                                            list-type="text"
                                            :show-file-list="false"
                                            :disabled="disabledAll"
                                            :on-success="function (res, file, fileList) {return uploadFileSuccess(res, file, fileList, '托管行意见')}"
                                        >
                                            <el-button size="small" icon="el-icon-plus" style="border:none" :disabled="disabledAll">添加文件</el-button>
                                        </el-upload>
                                    </div>
                                    <UploadFileShow
                                        :fileList="fileList2"
                                        @emitDownLoadFile="downLoadFileBtn"
                                        @emitConfirmDelFile="confirmDelFile2"
                                    ></UploadFileShow>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col :span="24">
                                <el-form-item label="行业调研:">
                                    <el-input
                                        type="textarea"
                                        v-model="indexClause.industryResearch"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:67vw"
                                        :disabled="disabledAll"
                                    ></el-input>
                                    <div style="display:flex">
                                        <div>附件:</div>
                                        <el-upload  
                                            multiple
                                            class="upload-demo"
                                            :action="actionUrl" 
                                            :headers='headerObj'
                                            :with-credentials='true'
                                            list-type="text" 
                                            :show-file-list="false"
                                            :disabled="disabledAll"
                                            :on-success="function (res, file, fileList) {return uploadFileSuccess(res, file, fileList, '行业调研')}"
                                        >
                                            <el-button size="small" icon="el-icon-plus" style="border:none" :disabled="disabledAll">添加文件</el-button>
                                        </el-upload>
                                    </div>
                                    <UploadFileShow
                                        :fileList="fileList3"
                                        @emitDownLoadFile="downLoadFileBtn"
                                        @emitConfirmDelFile="confirmDelFile3"
                                    ></UploadFileShow>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </template>

            <!-- 超限设置 -->
            <template v-if="['产品新增', '产品修改', '产品查看', '产品复核修改', '产品复核查看'].includes(sourceSettteingType)">
                <div class="card-title">超限设置</div>
                <div class="card-content">
                    <el-form :inline="true" :model="indexClause" label-width="130px">
                        <el-row class="form-row">
                            <el-col :span="8">
                                <el-form-item label="是否可被动超限:">
                                    <el-select v-model="indexClause.passiveTransfinite" placeholder="请选择" size="mini" :disabled="disabledAll">
                                        <el-option label="是" :value="true"></el-option>
                                        <el-option label="否" :value="false"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="超限调整时间:">
                                    <span v-if="indexClause.transfiniteType" style="position: absolute;left:-10px;color: red">*</span>
                                    <el-select v-model="indexClause.transfiniteType" placeholder="请选择" size="mini" :disabled="!indexClause.passiveTransfinite || disabledAll">
                                        <el-option label="交易所交易日" value="1"></el-option>
                                        <el-option label="银行间交易日" value="2"></el-option>
                                        <el-option label="自然日" value="3"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="2">
                                <el-form-item label="">
                                    <!-- <el-input-number
                                        v-model="indexClause.transfiniteTime"
                                        controls-position="right"
                                        :min="1"
                                        size="mini"
                                    ></el-input-number> -->
                                    <el-input
                                        :disabled="!indexClause.passiveTransfinite || disabledAll"
                                        v-model="indexClause.transfiniteTime"
                                        size="mini"
                                        maxlength="3"
                                        @blur="blurDay($event)"
                                        @focus="blurDay($event)"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="1">
                                <div style="margin-top: 8px">天</div>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </template>

            <!-- 条款适用产品范围 -->
            <template v-if="['外规新增', '外规修改', '外规查看', '外规复核修改', '外规复核查看', '外规单个复制'].includes(sourceSettteingType)">
                <div class="card-title">条款适用产品范围</div>
                <div class="card-content">
                    <el-form :inline="true" :model="indexClause" label-width="130px">
                        <el-row class="form-row">
                            <el-col :span="8">
                                <el-form-item label="是否可被动超限:">
                                    <span style="position: absolute;left:-10px;color: red">*</span>
                                    <el-select v-model="indexClause.passiveTransfinite" placeholder="请选择" size="mini" :disabled="disabledAll">
                                        <el-option label="是" :value="true"></el-option>
                                        <el-option label="否" :value="false"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="超限调整时间:">
                                    <span v-if="indexClause.passiveTransfinite" style="position: absolute;left:-10px;color: red">*</span>
                                    <el-select v-model="indexClause.transfiniteType" placeholder="请选择" size="mini" :disabled="!indexClause.passiveTransfinite || disabledAll" clearable>
                                        <el-option label="交易所交易日" value="1"></el-option>
                                        <el-option label="银行间交易日" value="2"></el-option>
                                        <el-option label="自然日" value="3"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="2">
                                <el-form-item label="">
                                    <!-- <el-input-number
                                        :disabled="!indexClause.passiveTransfinite"
                                        v-model="indexClause.transfiniteTime"
                                        controls-position="right"
                                        :min="0"
                                        size="mini"
                                    ></el-input-number> -->
                                    <el-input
                                        :disabled="!indexClause.passiveTransfinite || disabledAll"
                                        v-model="indexClause.transfiniteTime"
                                        size="mini"
                                        maxlength="3"
                                        @blur="blurDay($event)"
                                        @focus="blurDay($event)"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="1">
                                <div style="margin-top: 8px">天</div>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col :span="2">
                                <el-form-item label="">
                                    <el-checkbox v-model="indexClause.publicOffering" style="margin-left:20px" :disabled="disabledAll">公募产品</el-checkbox>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="适用产品类型:">
                                    <el-select v-model="indexClause.suitPublicFundType" placeholder="请选择" size="mini" clearable :disabled="!indexClause.publicOffering || disabledAll">
                                        <el-option
                                            v-for="item in FundTypes"
                                            :key="item.dictKey"
                                            :value="item.dictKey"
                                            :label="item.dictKey + ' ' + item.dictKeyName"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="豁免产品类型:">
                                    <el-select v-model="indexClause.excludePublicFundType" placeholder="请选择" size="mini" clearable :disabled="!indexClause.publicOffering || disabledAll">
                                        <el-option
                                            v-for="item in FundTypes"
                                            :key="item.dictKey"
                                            :value="item.dictKey"
                                            :label="item.dictKey + ' ' + item.dictKeyName"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col :span="2">
                                <el-form-item label="">
                                    <el-checkbox v-model="indexClause.privatePlacement" style="margin-left:20px" :disabled="disabledAll">私募产品</el-checkbox>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="适用产品类型:">
                                    <el-select v-model="indexClause.suitPrivateFundType" placeholder="请选择" size="mini" clearable :disabled="!indexClause.privatePlacement || disabledAll">
                                        <el-option
                                            v-for="item in FundTypes"
                                            :key="item.dictKey"
                                            :value="item.dictKey"
                                            :label="item.dictKey + ' ' + item.dictKeyName"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="豁免产品类型:">
                                    <el-select v-model="indexClause.excludePrivateFundType" placeholder="请选择" size="mini" clearable :disabled="!indexClause.privatePlacement || disabledAll">
                                        <el-option
                                            v-for="item in FundTypes"
                                            :key="item.dictKey"
                                            :value="item.dictKey"
                                            :label="item.dictKey + ' ' + item.dictKeyName"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row class="form-row">
                            <el-col :span="2">
                                <el-form-item label="">
                                    <el-checkbox v-model="indexClause.cargoBase" style="margin-left:20px" :disabled="disabledAll">货基产品</el-checkbox>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="适用产品类型:">
                                    <el-select v-model="indexClause.suitCargoFundType" placeholder="请选择" size="mini" clearable :disabled="!indexClause.cargoBase || disabledAll">
                                        <el-option
                                            v-for="item in FundTypes"
                                            :key="item.dictKey"
                                            :value="item.dictKey"
                                            :label="item.dictKey + ' ' + item.dictKeyName"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </template>

            <!-- 系统配置说明 -->
            <template  v-if="!['外规多个复制'].includes(sourceSettteingType)">
                <div style="display:flex;justify-content: space-between;">
                    <div style="width:49%">
                        <div class="card-title">实时系统配置说明</div>
                        <div class="card-content">
                            <el-form ref="form" :model="indexClause" label-width="160px">
                                <el-form-item label="实时系统支持情况:">
                                    <el-select v-model="indexClause.realTimeSupport" placeholder="请选择" size="mini" :disabled="disabledAll" clearable>
                                        <el-option label="支持" value="1"></el-option>
                                        <el-option label="部分支持" value="2"></el-option>
                                        <el-option label="不支持" value="3"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="可配置说明:">
                                    <el-input
                                        type="textarea"
                                        v-model="realTimeSupport.configurableDescription"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:90%"
                                         :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                                <el-form-item label="不可配置说明:">
                                    <el-input
                                        type="textarea"
                                        v-model="realTimeSupport.unconfigurableDescription"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:90%"
                                         :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                                <el-form-item label="注意事项:">
                                    <el-input
                                        type="textarea"
                                        v-model="realTimeSupport.cautions"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:90%"
                                         :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                            </el-form>
                        </div>
                    </div>
                    <div style="width:49%">
                        <div class="card-title">恒生系统配置说明</div>
                        <div class="card-content">
                            <el-form ref="form" :model="indexClause" label-width="160px">
                                <el-form-item label="恒生系统支持情况:">
                                    <el-select v-model="indexClause.hdSupport" placeholder="请选择" size="mini" :disabled="disabledAll" clearable>
                                        <el-option label="支持" value="1"></el-option>
                                        <el-option label="部分支持" value="2"></el-option>
                                        <el-option label="不支持" value="3"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="可配置说明:">
                                    <el-input
                                        type="textarea"
                                        v-model="hdSupport.configurableDescription"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:90%"
                                         :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                                <el-form-item label="不可配置说明:">
                                    <el-input
                                        type="textarea"
                                        v-model="hdSupport.unconfigurableDescription"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:90%"
                                         :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                                <el-form-item label="注意事项:">
                                    <el-input
                                        type="textarea"
                                        v-model="hdSupport.cautions"
                                        :autosize="{ minRows: 4, maxRows: 4 }"
                                        style="width:90%"
                                         :disabled="disabledAll"
                                    ></el-input>
                                </el-form-item>
                            </el-form>
                        </div>
                    </div>
                </div>
            </template>
            <template v-if="['外规修改', '产品修改', '外规复核修改', '产品复核修改'].includes(sourceSettteingType)">
                <div style="margin: 20px auto">
                    <span>修改原因：</span>
                    <el-input v-model="indexClause.modifyReason" size="mini" style="width: 80%"/>
                </div>
            </template>
            <span slot="footer" class="dialog-footer">
                <el-button @click="handleTreatyArticle('cancel')">取 消</el-button>
                <el-button 
                    type="primary" 
                    @click="handleTreatyArticle('confirm')" 
                    v-if="['外规新增', '外规修改', '外规复核修改', '产品复核修改', '外规单个复制', '产品新增', '产品修改', '外规多个复制'].includes(sourceSettteingType)"
                >确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script lang="ts">
import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import RiskIconButton from '@/common/components/risk-icon-button.vue';
import UploadFileShow from '../commom/upload-file-show.vue'
import { getUser } from '@/utils/user-util';
import { SGU_CACHE } from '@/utils/diction-const-util';
import { downLoadFile } from '@/utils/request';
import { values } from 'xe-utils/methods';
@Component({
    name: 'TreatyArticleDialog',
    components: {
        RiskIconButton,
        UploadFileShow,
    },
})
export default class TreatyArticleDialog extends Vue {
    @Prop() addTreatyDialog; // 新增合规条款弹窗显示
    @Prop() sourceSettteingType; // 条款设置弹窗类型 -- 判断是新增、编辑、查看状态
    @Prop() treeNodeData?; // 当前选择的树节点数据
    @Prop() clauseCodeItem?; // 点击行code
    @Prop() clauseCodes?; // 多选条款
    @Prop() reviewItem?; // 复核行数据
    private dialogVisible: boolean = false;
    private indexSourceCodeSelect = []; // 来源类型select
    private indexSourceCodeSelect1 = []; // 来源名称select
    private VersionNums = [];
    private title = '';
    private FundTypes: any = []; // 产品类型
    private actionUrl = ''; // 附件上传url
    fundByFundTypeList = []; // 产品信息下拉框
    treatyList = {
        serial: '', // 条款序号
        productInfo: '', // 产品信息
        clauseType: '', // 条款类型
        status: '', // 状态
    };
    fileList1 = []; 
    fileList2 = []; 
    fileList3 = []; 
    indexClause = {
        indexSourceCode: '',
        // 条款基础信息
        clauseCode: '', // 条款基础信息
        sourceType: '', // 来源类型
        indexSourceName: '', // 来源名称
        clauseStatus: true, // 是否禁用
        versionNumber: '', // 版本号
        clauseNo: '', // 条款号
        clauseText: '', // 条款原文
        executiveStandard: '', // 执行标准
        executiveStandardFileCode: [], // 执行标准文件编码
        depositOpinions: '', // 托管行意见
        depositOpinionsFileCode: [], // 托管行意见文件编码
        industryResearch: '', // 行业调研
        industryResearchFileCode: [], // 行业调研文件编码
        // 口径引用信息
        outerRuleCaliber: '', // 外规类口径
        projectCaliber: '', // 项目类口径
        // 条款适用产品范围
        passiveTransfinite: false, // 是否可被动超限
        transfiniteType: '', // 超限调整时间类型
        transfiniteTime: '0', // 超限调整时间
        publicOffering: false, // 是否公募产品
        suitPublicFundType: '', // 适用产品类型
        excludePublicFundType: '', // 豁免产品类型
        privatePlacement: false, // 是否私募产品
        suitPrivateFundType: '', // 适用私募产品类型
        excludePrivateFundType: '', // 豁免私募产品类型
        cargoBase: false, // 是否货基产品
        suitCargoFundType: '', // 适用货基产品类型
        // 系统配置说明
        realTimeSupport: '', // 实时系统支持情况, 
        hdSupport: '', // 恒生系统配置说明, 
        supportText: '', // 支持情况文本 JSON

        belongFund: '', // 产品信息
        fundType: '', // 产品类型
        indexType: '', // 区分外规类指标、产品类指标
        modifyReason: '', // 修改原因
        originalClauseCode: ''
    }
    realTimeSupport= { // 实时系统配置说明
        configurableDescription: '',
        unconfigurableDescription: '',
        cautions: ''
    }
    hdSupport= { // 恒生系统配置说明
        configurableDescription: '',
        unconfigurableDescription: '',
        cautions: ''
    }
    headerObj= {
        Authentication: getUser().sessionId,
    }
    disabledAll = false;
    removal = { 
        sourceType: '', // 迁移来源类型
        indexSourceName: '', // 迁移来源名称
    }
    created() {
        const baseUrl = process.env.ENV_CONFIG === 'project' ? window.project_config.baseUrlApi : process.env.BASE_URL_API;
        this.actionUrl = baseUrl + '/system/upload/1'
    }
    @Watch('addTreatyDialog')
    async handleAddTreatyDialog(val) {
        this.dialogVisible = val;
        if (val == true) {
            this.title = '合规条款' + this.sourceSettteingType.slice(this.sourceSettteingType.length - 2, this.sourceSettteingType.length);
            this.FundTypes = await SGU_CACHE('FundType', '/dict/list/code/Y_000002', []);
            // 查看状态禁止修改
            if (['外规查看', '外规复核查看', '产品查看', '产品复核查看'].includes(this.sourceSettteingType)) {
                this.disabledAll = true;
            }
            // 来源类型、来源名称
            if (!['外规单个复制', '外规多个复制'].includes(this.sourceSettteingType)) {
                this.getIndexSourceSelect1('');
                this.getClauseCode();
            }
            
            if (['外规新增'].includes(this.sourceSettteingType)) {
                this.getVersionNums(this.treeNodeData.id);
                this.getIndexSourceSelect();
                this.indexClause.sourceType = this.treeNodeData.parentId;
                this.indexClause.indexSourceName = this.treeNodeData.id;
                this.indexClause.indexSourceCode = this.treeNodeData.id;
                this.indexClause.indexType = '1';
            } else if (['外规修改', '外规查看'].includes(this.sourceSettteingType)) {
                this.getIndexSourceSelect();
                this.getVersionNums(this.clauseCodeItem.indexSourceCode);
                this.getDetailData(this.clauseCodeItem.clauseCode);
            } else if (['产品新增'].includes(this.sourceSettteingType)) {
                this.getVersionNums(this.treeNodeData.id);
                this.getFundByFundType(this.treeNodeData.fundType);
                this.indexClause.fundType = this.treeNodeData.fundType;
                this.indexClause.belongFund = this.treeNodeData.fundCode;
                this.indexClause.indexSourceName = this.treeNodeData.id;
                this.indexClause.indexSourceCode = this.treeNodeData.id;
                this.indexClause.indexType = '2';
            } else if (['产品修改', '产品查看'].includes(this.sourceSettteingType)) {
                this.getVersionNums(this.clauseCodeItem.indexSourceCode);
                this.getFundByFundType(this.treeNodeData.belongFund)
                this.indexClause.belongFund = this.treeNodeData.id;
                this.getDetailData(this.clauseCodeItem.clauseCode);
            } else if (['外规单个复制', '外规多个复制'].includes(this.sourceSettteingType)) {
                this.getIndexSourceSelect();
                if (['外规单个复制'].includes(this.sourceSettteingType)) {
                    this.getVersionNums(this.treeNodeData.id);
                    this.getDetailData(this.clauseCodes);
                }
            } else if (['外规复核修改', '外规复核查看', '产品复核修改', '产品复核查看'].includes(this.sourceSettteingType)) {
                this.getVersionNums(this.reviewItem.indexSourceCode);
                this.getFundByFundType('');
                this.getIndexSourceSelect();
                this.getClauseCheckDetail(this.reviewItem);
            }
        } else if (val == false) {
            this.indexClause = {
                indexSourceCode: '',
                // 条款基础信息
                clauseCode: '', // 条款基础信息
                sourceType: '', // 来源类型
                indexSourceName: '', // 来源名称
                clauseStatus: true, // 是否禁用
                versionNumber: '', // 版本号
                clauseNo: '', // 条款号
                clauseText: '', // 条款原文
                executiveStandard: '', // 执行标准
                executiveStandardFileCode: [], // 执行标准文件编码
                depositOpinions: '', // 托管行意见
                depositOpinionsFileCode: [], // 托管行意见文件编码
                industryResearch: '', // 行业调研
                industryResearchFileCode: [], // 行业调研文件编码
                // 口径引用信息
                outerRuleCaliber: '', // 外规类口径
                projectCaliber: '', // 项目类口径
                // 条款适用产品范围
                passiveTransfinite: false, // 是否可被动超限
                transfiniteType: '', // 超限调整时间
                transfiniteTime: '0', // 超限调整时间
                publicOffering: false, // 是否公募产品
                suitPublicFundType: '', // 适用产品类型
                excludePublicFundType: '', // 豁免产品类型
                privatePlacement: false, // 是否私募产品
                suitPrivateFundType: '', // 适用私募产品类型
                excludePrivateFundType: '', // 豁免私募产品类型
                cargoBase: false, // 是否货基产品
                suitCargoFundType: '', // 适用货基产品类型
                // 系统配置说明
                realTimeSupport: '', // 实时系统支持情况, 
                hdSupport: '', // 恒生系统配置说明, 
                supportText: '', // 支持情况文本 JSON
                belongFund: '', // 产品信息
                fundType: '', // 产品类型
                indexType: '', // 区分外规类指标、产品类指标
                modifyReason: '', // 修改原因
                originalClauseCode: ''
            }
            this.realTimeSupport = { // 实时系统配置说明
                configurableDescription: '',
                unconfigurableDescription: '',
                cautions: ''
            }
            this.hdSupport = { // 恒生系统配置说明
                configurableDescription: '',
                unconfigurableDescription: '',
                cautions: ''
            }
            this.removal = {
                sourceType: '',
                indexSourceName: ''
            }
            this.fileList1 = [];
            this.fileList2 = [];
            this.fileList3 = [];
            this.disabledAll = false;
            this.indexSourceCodeSelect = [];
            this.indexSourceCodeSelect1 = [];
        }
    }
    @Watch('dialogVisible')
    handleDialogVisible(val) {
        this.$emit('emitTreatyArticle', val, '')
    }
    @Watch('addTreatyDialog')
    handleAddSourceDialog(val) {
        this.dialogVisible = val
    }
    // 获取复核详情
    getClauseCheckDetail(param) {
        this.$axios.get('/indexClause/getClauseCheckDetail/' + param.serialNo + '/' + param.changeNo + '/' + param.clauseCode).then((res: any) => {
            this.indexClause = res;
            this.fileList1 = [];
            this.fileList2 = [];
            this.fileList3 = [];
            let supportText = JSON.parse(res.supportText)
            this.realTimeSupport = {...supportText[0]}
            this.hdSupport = {...supportText[1]}
            // if (this.sourceSettteingType == '外规复核修改') {
            //     this.indexClause.indexType = '1';
            // }
            res.executiveStandardFiles.forEach(item => {
                this.fileList1.push(
                    {
                        name: item.fileName,
                        fileNo: item.fileNo
                    }
                )    
            })
            res.depositOpinionsFiles.forEach(item => {
                this.fileList2.push(
                    {
                        name: item.fileName,
                        fileNo: item.fileNo
                    }
                )    
            })
            res.industryResearchFiles.forEach(item => {
                this.fileList3.push(
                    {
                        name: item.fileName,
                        fileNo: item.fileNo
                    }
                )    
            })
        }); 
    }
    // 编辑
    getDetailData(data) {
        this.$axios.post('/indexClause/detail/' + data).then((res: any) => {
            if (res) {
                this.fileList1 = [];
                this.fileList2 = [];
                this.fileList3 = [];
                this.indexClause = res;
                // if (this.sourceSettteingType == '外规单个复制') {
                //     this.indexClause.versionNumber = '';
                //     this.indexClause.indexType = '1';
                // }
                if (['外规修改', '外规单个复制'].includes(this.sourceSettteingType)) {
                    this.indexClause.indexType = '1';
                } else if (this.sourceSettteingType == '产品修改') {
                    this.indexClause.indexType = '2';
                }
                let supportText = JSON.parse(res.supportText)
                this.realTimeSupport = {...supportText[0]}
                this.hdSupport = {...supportText[1]}
                if (res.executiveStandardFiles) {
                    res.executiveStandardFiles.forEach(item => {
                        this.fileList1.push({ name: item.fileName, fileNo: item.fileNo })    
                    })    
                }
                if (res.depositOpinionsFiles) {
                    res.depositOpinionsFiles.forEach(item => {
                        this.fileList2.push({ name: item.fileName, fileNo: item.fileNo })    
                    })    
                }
                if (res.industryResearchFiles) {
                    res.industryResearchFiles.forEach(item => {
                        this.fileList3.push({ name: item.fileName, fileNo: item.fileNo })    
                    })    
                }
            }
        });
    }
    // 获取条款序号
    getClauseCode() {
        this.$axios.get('/indexClause/getClauseCode').then((res: any) => {
            this.indexClause.clauseCode = res;
        }); 
    }
    // 根据产品类型获取产品
    getFundByFundType(dictKey) {
        this.$axios.post('/indexClause/getFundByFundType', {
            dictKey: dictKey
        }).then((res: any) => {
            this.fundByFundTypeList = []
            if (res) { 
                res.forEach(item => this.fundByFundTypeList.push(item))
            }
        }); 
    }
    // 迁移来源类型change
    changeSourceType(value) {
        this.getIndexSourceSelect1(value);
    }
    // 条目来源分类下拉-三级
    getIndexSourceSelect() {
        this.$axios.post('/indexSource/indexSourceSelect', {
            dictCode: '',
            dictKey: '',
            dictKeyName: '',
            innerDictionary: '',
            param1: [],
            param2: '',
            param3: '',
            param4: '',
        }).then((res: any) => {
            if (res) {
                this.indexSourceCodeSelect = [];
                res.forEach(item => this.indexSourceCodeSelect.push(item))
            }
        });
    }
    // 条目来源分类下拉-四级
    getIndexSourceSelect1(data) {
        this.$axios.post('/indexSource/indexSourceSelect1', {
            dictCode: '',
            dictKey: data,
            dictKeyName: '',
            innerDictionary: '',
            param1: [],
            param2: '',
            param3: '',
            param4: '',
        }).then((res: any) => {
            if (res) {
                this.indexSourceCodeSelect1 = [];
                res.forEach(item => this.indexSourceCodeSelect1.push(item))
            }
        });
    }
    // 条目来源分类下拉-三级
    getClauseCodeCkSelect() {
        this.$axios.post('/indexClause/clauseCodeCkSelect', {
            dictCode: '',
            dictKey: '',
            dictKeyName: '',
            innerDictionary: '',
            param1: [],
            param2: '',
            param3: '',
            param4: '',
        }).then((res: any) => {
            if (res) {
                this.indexSourceCodeSelect = [];
                res.forEach(item => this.indexSourceCodeSelect.push(item))
            }
        });
    }
    // 获取当前来源的所有版本号
    getVersionNums(indexCode) {
        this.$axios.post('/indexSource/getVersionNums/' + indexCode).then((res: any) => {
            if (res) {
                this.VersionNums = [];
                res.forEach(item => this.VersionNums.push(item))
            }
        });
    }
    handleTreatyArticle(parameter) {
        if (parameter == 'cancel') {
            this.$emit('emitTreatyArticle', false, '')
        } else if (parameter == 'confirm') {
            if (this.indexClause.clauseCode == '' && this.sourceSettteingType != '外规多个复制') {
                this.yh_message_warn('条款序号不可为空!');
                return
            }
            if (this.indexClause.sourceType == '' && ['外规新增', '外规修改', '外规查看', '外规复核修改', '外规复核查看', '外规单个复制'].includes(this.sourceSettteingType)) {
                this.yh_message_warn('来源类型不可为空!');
                return
            }
            if (this.indexClause.indexSourceName == '' && ['外规新增', '外规修改', '外规查看', '外规复核修改', '外规复核查看', '外规单个复制'].includes(this.sourceSettteingType)) {
                this.yh_message_warn('来源名称不可为空!');
                return
            }
            if (this.indexClause.fundType == '' && ['产品新增', '产品修改', '产品查看'].includes(this.sourceSettteingType)) {
                this.yh_message_warn('产品类型不可为空!');
                return
            }
            if (this.indexClause.belongFund == '' && ['产品新增', '产品修改', '产品查看'].includes(this.sourceSettteingType)) {
                this.yh_message_warn('产品信息不可为空!');
                return
            }
            if (this.indexClause.versionNumber == '' && this.sourceSettteingType != '外规多个复制') {
                this.yh_message_warn('版本号不可为空!');
                return
            }
            if (this.indexClause.clauseText == '' && this.sourceSettteingType != '外规多个复制') {
                this.yh_message_warn('条款原文不可为空!');
                return
            }
            if (this.indexClause.executiveStandard == '' && this.sourceSettteingType != '外规多个复制') {
                this.yh_message_warn('执行标准不可为空!');
                return
            }

            if (this.indexClause.passiveTransfinite && this.indexClause.transfiniteType == '' && this.sourceSettteingType != '外规多个复制') {
                this.yh_message_warn('超限调整时间不可为空!');
                return
            }
            if (['外规单个复制', '外规多个复制'].includes(this.sourceSettteingType)) {
                if (this.removal.sourceType == '') {
                    this.yh_message_warn('迁移来源类型不可为空！');
                    return
                }
                if (this.removal.indexSourceName == '') {
                    this.yh_message_warn('迁移来源名称不可为空！');
                    return
                }
                if (this.sourceSettteingType == '外规单个复制') {
                    let jsonText = []
                    jsonText.push(this.realTimeSupport)
                    jsonText.push(this.hdSupport)
                    this.indexClause.supportText = JSON.stringify(jsonText || [])
                    this.indexClause.executiveStandardFileCode = [];
                    this.indexClause.depositOpinionsFileCode = [];
                    this.indexClause.industryResearchFileCode = [];
                    this.fileList1.forEach(item => this.indexClause.executiveStandardFileCode.push(item.fileNo));
                    this.fileList2.forEach(item => this.indexClause.depositOpinionsFileCode.push(item.fileNo));
                    this.fileList3.forEach(item => this.indexClause.industryResearchFileCode.push(item.fileNo));
                    this.indexClause.sourceType = this.removal.sourceType;
                    this.indexClause.indexSourceName = this.removal.indexSourceName;
                    this.indexClause.indexSourceCode = this.removal.indexSourceName;
                    this.indexClause.clauseCode = '';
                    this.indexClause.originalClauseCode = this.clauseCodes[0];
                    if (this.indexClause.passiveTransfinite == false) {
                        this.indexClause.transfiniteType = ''
                        this.indexClause.transfiniteTime = '0'
                    }
                    this.$axios.post('/indexClause/multipleCopy', this.indexClause).then((res: any) => {
                        this.yh_message_success(this.sourceSettteingType + '成功');
                        this.$emit('emitTreatyArticle', false, 'query');
                    }); 
                } else if (this.sourceSettteingType == '外规多个复制') {
                    this.$axios.post('/indexClause/multipleCopy', {
                        sourceType: this.removal.sourceType,
                        indexSourceName: this.removal.indexSourceName,
                        indexSourceCode: this.removal.indexSourceName,
                        // versionNumber: this.indexClause.versionNumber,
                        // clauseNo: this.indexClause.clauseNo,
                        indexClauseCodes: this.clauseCodes
                    }).then((res: any) => {
                        this.yh_message_success('迁移复制成功！');
                        this.dialogVisible = false;
                    });     
                }
            } else if (['外规新增', '产品新增', '外规修改', '产品修改', '外规复核修改', '产品复核修改'].includes(this.sourceSettteingType)) {
                let jsonText = []
                jsonText.push(this.realTimeSupport)
                jsonText.push(this.hdSupport)
                this.indexClause.supportText = JSON.stringify(jsonText || [])
                this.indexClause.executiveStandardFileCode = [];
                this.indexClause.depositOpinionsFileCode = [];
                this.indexClause.industryResearchFileCode = [];
                this.fileList1.forEach(item => this.indexClause.executiveStandardFileCode.push(item.fileNo))
                this.fileList2.forEach(item => this.indexClause.depositOpinionsFileCode.push(item.fileNo))
                this.fileList3.forEach(item => this.indexClause.industryResearchFileCode.push(item.fileNo))
                if (this.indexClause.passiveTransfinite == false) {
                    this.indexClause.transfiniteType = ''
                    this.indexClause.transfiniteTime = '0'
                }

                if (['外规新增', '产品新增'].includes(this.sourceSettteingType)) {
                    this.$axios.post('/indexClause/add', this.indexClause).then((res: any) => {
                        this.yh_message_success(this.sourceSettteingType + '成功');
                        this.$emit('emitTreatyArticle', false, 'query');
                    }); 
                } else if (['外规修改', '产品修改'].includes(this.sourceSettteingType)) {
                    this.$axios.post('/indexClause/update', this.indexClause).then((res: any) => {
                        this.yh_message_success(this.sourceSettteingType + '成功');
                        this.$emit('emitTreatyArticle', false, 'query');
                    }).catch(() => { this.$emit('emitTreatyArticle', true, 'query') });
                } else if (['外规复核修改', '产品复核修改'].includes(this.sourceSettteingType)) {
                    this.$axios.post('/indexClause/check/update', this.indexClause).then((res: any) => {
                        this.yh_message_success(this.sourceSettteingType + '成功');
                        this.dialogVisible = false;
                    });
                }
            }
        }
    }
    // 文件上传
    uploadFileSuccess(res, file, fileList, type) {
        if (type == '执行标准') {
            this.fileList1.push(
                {
                    name: res.data.fileName,
                    url: res.data.relativePath,
                    fileNo: res.data.fileNo
                }
            )
        } else if (type == '托管行意见') {
            this.fileList2.push(
                {
                    name: res.data.fileName,
                    url: res.data.relativePath,
                    fileNo: res.data.fileNo
                }
            )
        } else if (type == '行业调研') {
            this.fileList3.push(
                {
                    name: res.data.fileName,
                    url: res.data.relativePath,
                    fileNo: res.data.fileNo
                }
            )
        }
    }
    // 下载文件
    downLoadFileBtn(param) {
        downLoadFile({
            url: '/system/download/file/' + param.fileNo,
            method: 'get',
        });
    }
    // 删除已上传文件
    confirmDelFile1(param) {
        this.fileList1.forEach((item, index) => {
            if (item.fileNo == param.fileNo) {
                this.fileList1.splice(index, 1)
            }
        })
    }
    confirmDelFile2(param) {
        this.fileList2.forEach((item, index) => {
            if (item.fileNo == param.fileNo) {
                this.fileList2.splice(index, 1)
            }
        })
    }
    confirmDelFile3(param) {
        this.fileList3.forEach((item, index) => {
            if (item.fileNo == param.fileNo) {
                this.fileList3.splice(index, 1)
            }
        })
    }
    blurDay(value) {
        this.indexClause.transfiniteTime = this.indexClause.transfiniteTime.replace(/^(0+)|[^\d]+/g, '')
        return this.indexClause.transfiniteTime 
    }
}
</script>
<style lang="scss" scoped>
.treaty-title {
    height: 25px;
    line-height: 20px;
    margin-top: -10px;
}
.card-title {
    color: red;
    height: 25px;
    line-height: 25px;
    margin: 15px 0px 2px 0;
}
.card-content {
    width: 100%;
    border: 2px solid rgba(174, 174, 174, 0.5);
    padding-top: 10px;
}
/deep/ .el-dialog {
    overflow: auto;
}
.uploadBtn:hover {
    background: #f5f7fa;
}
.fileName:hover {
    text-decoration: underline;
    color: #48a2ff;
}
</style>
